package com.example.demo.service;

import com.example.demo.model.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;

import java.util.List;

/**
 * 功能描述：
 *
 * @Author: Zhanghf
 * @Date: 2021/12/14 19:34
 */
@Service
public class TypeService {
    @Autowired
    private BookCacheService bookCacheService;
    public void classify(String type, List<Book> latestover, List<Book> latestupdate, Model model)
    {
        switch (type) {
            case "xuanhuan":
                type = "玄幻奇幻";
                List<Book> topxuanhuan = bookCacheService.hitsRank("玄幻奇幻");
                latestover = bookCacheService.typeLatestOver("玄幻奇幻");
                latestupdate = bookCacheService.typeLatestUpdate("玄幻奇幻");
                model.addAttribute("top", topxuanhuan);
                model.addAttribute("latestover", latestover);
                model.addAttribute("latestupdate", latestupdate);
                model.addAttribute("default", "心潮澎湃，无限幻想，迎风挥击千层浪，少年不败热血！");
                break;
            case "dushi":
                type = " 都市言情";
                List<Book> topdushi = bookCacheService.hitsRank("都市言情");

                latestover = bookCacheService.typeLatestOver("都市言情");
                latestupdate = bookCacheService.typeLatestUpdate("都市言情");
                model.addAttribute("top", topdushi);
                model.addAttribute("latestover", latestover);
                model.addAttribute("latestupdate", latestupdate);
                model.addAttribute("default", "重生过去，畅想未来，梦幻现实，再塑传奇人生");
                break;
            case "wuxia":
                type = "仙侠武侠";
                List<Book> topwuxia = bookCacheService.hitsRank("仙侠武侠");

                latestover = bookCacheService.typeLatestOver("仙侠武侠");
                latestupdate = bookCacheService.typeLatestUpdate("仙侠武侠");
                model.addAttribute("top", topwuxia);
                model.addAttribute("latestover", latestover);
                model.addAttribute("latestupdate", latestupdate);
                model.addAttribute("default", "修仙觅长生，热血任逍遥，踏莲曳波涤剑骨，凭虚御风塑圣魂！");
                break;
            case "kehuan":
                type = "科幻灵异";
                List<Book> topkehuan = bookCacheService.hitsRank("科幻灵异");

                latestover = bookCacheService.typeLatestOver("科幻灵异");
                latestupdate = bookCacheService.typeLatestUpdate("科幻灵异");
                model.addAttribute("top", topkehuan);
                model.addAttribute("latestover", latestover);
                model.addAttribute("latestupdate", latestupdate);
                model.addAttribute("default", "星海漫游，时空穿梭，机械科技，目标是未知的星辰大海！");
                break;
            case "tongren":
                type = "同人网游";
                List<Book> toptongren = bookCacheService.hitsRank("同人网游");
                latestover = bookCacheService.typeLatestOver("同人网游");
                latestupdate = bookCacheService.typeLatestUpdate("同人网游");
                model.addAttribute("top", toptongren);
                model.addAttribute("latestover", latestover);
                model.addAttribute("latestupdate", latestupdate);
                model.addAttribute("default", "肆意挥洒激情的游戏人生，打破现实框架的无尽幻想！");
                break;
            case "chuanyue":
                type = "穿越历史";
                List<Book> topchuanyue = bookCacheService.hitsRank("穿越历史");
                latestover = bookCacheService.typeLatestOver("穿越历史");
                latestupdate = bookCacheService.typeLatestUpdate("穿越历史");
                model.addAttribute("top", topchuanyue);
                model.addAttribute("latestover", latestover);
                model.addAttribute("latestupdate", latestupdate);
                model.addAttribute("default", "醒掌天下权，醉卧美人膝，五千年风华烟雨，是非成败转头空！");
                break;
            default:
                type = "index";
        }
        model.addAttribute("type", type);
    }

}
